//
//  XHInterListViewController.m
//  XHAdSDKTest
//
//  Created by 陈俭红 on 2022/2/15.
//

#import "XHInterListViewController.h"

//广告头文件
#import <XHAdSDK/XHAdSDK.h>

@interface XHInterListViewController ()<XHInterAdDelegate>

@property (nonatomic, strong)UIButton * normalBtn;
/* <#name#> */
@property (nonatomic, strong) XHAdCenter *center;
@end

@implementation XHInterListViewController

//MARK: Cycle Methods
- (void)viewDidLoad{
    [super viewDidLoad];
    
    self.title = @"插屏广告";
    
    [self addAllViews];
}

//MARK: Custom Methods
- (void)addAllViews{
    [self.view addSubview:self.normalBtn];
}

//MARK: Getter Methods
- (UIButton *)normalBtn{
    if (!_normalBtn) {
        _normalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _normalBtn.frame = CGRectMake((self.view.frame.size.width - 150) / 2, 100, 150, 44);
        [_normalBtn setTitle:@"插屏广告" forState:UIControlStateNormal];
        [_normalBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _normalBtn.backgroundColor = [UIColor purpleColor];
        [_normalBtn addTarget:self action:@selector(playBtnAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _normalBtn;
}

- (void)playBtnAction {
    XHAdCenter * center = [XHAdCenter new];
    XHInterAdData * data = [XHInterAdData new];
    data.rootViewController = self;
    data.interDelegate = self;
    data.isPreload = YES;   //是否预加载 默认NO
    [center xh_showInterAd:data appId:@"248575688326512648"];
    self.center = center;
}

- (void)xh_onInterActionAdDidLoad {
    NSLog(@"广告预加载成功");
    [self.center xh_showPreloadInterAd];
}

/** 广告加载失败，msg加载失败说明（如果重新请求广告，注意：只重新请求一次）*/
- (void)xh_onInterActionAdFail:(NSString *)errorString{
    
}

/** 广告渲染成功 */
- (void)xh_onInterActionAdExposure{
    
}

/** 广告被关闭 */
- (void)xh_onInterActionAdDismiss{
    
}

/** 广告被点击 */
- (void)xh_onInterActionAdClicked{
    
}

/** 视频准备就绪开始播放（非视频广告不回调）*/
- (void)xh_onInterActionVideoReady{
    
}

/** 视频播放完成（非视频广告不回调）*/
- (void)xh_onInterActionVideoComplete{
    
}

@end
